var windowName = "siteWorker";
var Page;
apiready = function(){
    onWindowShow(function () {
        log("show")
        var cur = getLocData("curSite")
        Page.curSite = cur;
        getData(Page)
    })
    onWindowHide(function () {
    })
    console.log("index page is OK");
    Page = createVM("#Page",{
        //页面数据
        curSite:{},
        wait:[],
        done:[],
        tab:0
    },{
        //页面方法
        init:function () {
            var _this = this;

        }
        ,OnPullDownRefresh:function () {
            startPullDownRefresh()
            getData(this)
        }
        ,joinSite:function (id) {
            var _this = this;
            apiPost("/app/sign/set/site",{id:id,site:_this.curSite.id},function (res) {
                showToast(res.message)
                getData(_this)
            })
        }
        ,clearSite:function (id) {
            var _this = this;
            apiPost("/app/sign/clear/site",{id:id,site:_this.curSite.id},function (res) {
                showToast(res.message)
                getData(_this)
            })
        }
        ,delLog:function (id) {
            var _this = this;
            apiPost("/app/sign/del",{id:id,site:_this.curSite.id},function (res) {
                showToast(res.message)
                getData(_this)
            })
        }


    })

    Page.init()

}

function getData(_this) {
    startPullDownRefresh()
    apiGet("/app/sign/today",{site:_this.curSite.id},function (res) {
        _this.wait = res.data.wait
        _this.done = res.data.done
    })
}